package com.refusea.train.controller

import com.refusea.train.domain.entity.ClassGroup
import com.refusea.train.domain.entity.LessonSchedule
import com.refusea.train.domain.helper.LessonScheduleHelper
import com.refusea.train.domain.req.LessonHistoryReq
import com.refusea.train.domain.req.ManualScheduleReq
import com.refusea.train.domain.req.ScheduleQueryReq
import com.refusea.train.domain.vo.LessonScheduleStatus
import com.refusea.train.domain.vo.OccupiedSchedule
import com.refusea.train.domain.vo.PaginationVo
import com.refusea.train.domain.vo.RecentLessonSchedule
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * @author Zhang Yan 2024/4/12
 **/
@RestController
@RequestMapping("/api/private/lesson_schedule")
class LessonScheduleController(private val lessonScheduleHelper: LessonScheduleHelper) {


    @GetMapping("/summary")
    fun summary(): List<ClassGroup> {
        return lessonScheduleHelper.summary()
    }

    @GetMapping("/list")
    fun list(classGroupId: Int, thisWeek: Boolean): List<LessonSchedule> {
        return lessonScheduleHelper.list(classGroupId, thisWeek)
    }

    @GetMapping("/occupied")
    fun occupied(classGroupId: Int, thisWeek: Boolean, scheduleId: Int?): OccupiedSchedule {
        return lessonScheduleHelper.occupied(classGroupId, thisWeek)
    }

    @PostMapping("/save")
    fun save(@RequestBody req: ManualScheduleReq) {
        return lessonScheduleHelper.save(req)
    }

    @GetMapping("/unconfirmed_count")
    fun unconfirmedCount(): Int {
        return lessonScheduleHelper.unconfirmedCount()
    }

    @GetMapping("/unconfirmed")
    fun unconfirmed(): List<LessonSchedule> {
        return lessonScheduleHelper.unconfirmed()
    }

    @PostMapping("/confirm")
    fun confirm(@RequestBody req: List<Int>) {
        return lessonScheduleHelper.confirm(req)
    }

    @PostMapping("/history")
    fun history(@RequestBody req: LessonHistoryReq): PaginationVo {
        return lessonScheduleHelper.history(req)
    }

    @PostMapping("/schedules")
    fun schedules(@RequestBody req: ScheduleQueryReq): List<LessonSchedule> {
        return lessonScheduleHelper.schedules(req)
    }

    @GetMapping("/recent")
    fun recent(): List<RecentLessonSchedule> {
        return lessonScheduleHelper.recent()
    }

    @GetMapping("/schedule_status")
    fun scheduleStatus(): List<LessonScheduleStatus> {
        return lessonScheduleHelper.scheduleStatus()
    }
}
